function lst = grow(lst, newc)
%GROW Grows the capacity of list to meet the new requirment of capacity
%
% [ Syntax ]
%  - lst = grow(lst)
%  - lst = grow(lst, newc)
%
% [ History ]
%   - Created by Dahua Lin, on Jan 5, 2008
%

c0 = 16;

if nargin == 1
    cc = max(2 * capacity(lst), c0);
else
    if newc <= capacity(lst)
        return;
    end
    
    cc = capacity(lst);
    if cc < c0
        cc = c0;
    end
    
    while cc < newc
        cc = cc * 2;
    end
    
end

lst.items = [lst.items; cell(cc - capacity(lst), 1)];
